/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-06-21 17:01:31
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-07-10 15:10:43
 * @FilePath: \cxl-h5\src\utils\chart\baseChart.ts
 */
export default class BaseChart {
    w_Width = 0
    w_Height = 0
    ctx: CanvasRenderingContext2D
    constructor(eleName: string, h = 1.8) {
        this.w_Height = window.innerWidth * h
        this.w_Width = window.innerWidth * 2

        const dom = document.querySelector(eleName)
        const oCanvas = document.createElement('canvas')
        oCanvas.width = this.w_Width
        oCanvas.height = this.w_Height

        oCanvas.style.width = '100%'
        oCanvas.style.height = '100%'
        oCanvas.style.display = 'block'

        this.ctx = oCanvas.getContext('2d') as CanvasRenderingContext2D
        dom?.appendChild(oCanvas)

        console.log(dom)
    }
    calculateRatio(n: number) {
        return (this.w_Width * n) / 375
    }
}
